package com.qf.controller;
import com.qf.entity.R;
import com.qf.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;



/**
 * 商品表(Goods)表控制层
 *
 * @author makejava
 * @since 2023-04-08 15:33:37
 */
@RestController
@RequestMapping("/goods")
@Slf4j
public class GoodsController  {
    /**
     * 服务对象
     */
    @Resource
    private GoodsService goodsService;

    /**
     * 查找所有睡衣 (mark为0)
     * @return
     */
    @RequestMapping("/pajamaslist")
    public R queryPajamas(){
        //log.debug("[pajamaslist]   查询所有睡衣");
        return R.succ(goodsService.query().eq("mark",0).list());
    }

    /**
     * 查找所有睡袍(mark为1)
     * @return
     */
    @RequestMapping("/nightdresslist")
    public R queryNightdress(){
        //log.debug("[nightdresslist]   查询所有睡袍");
        return R.succ(goodsService.query().eq("mark",1).list());
    }

    /**
     * 根据商品id查找
     * @param id
     * @return
     */
    @RequestMapping("/queryById")
    public R queryByGId (Integer id){
        //log.debug("[queryById]   根据id查询单个商品");
        return R.succ(goodsService.query().eq("id",id).one());
    }


}

